import React, { forwardRef } from 'react';
import { List } from 'antd';
import NewsTitle from './components/title';
import NewsSource from './components/source';
import SummaryItem from './components/summaryItem';
import CardItem from './components/cardItem';
import { NewsItemProps } from '../index';

const { Item: ListItem } = List;

export interface NewsItemViewProps extends NewsItemProps {
  viewType: string;
  detail: string;
}

const NewsItem: React.FC<NewsItemViewProps> = forwardRef((props, ref) => {
  const { viewType, ImgUrl, Summary, detail, ID, newsKey, ...others } = props;
  switch (viewType) {
    case 'static':
    case 'roll':
      return (
        <div className="inbiz-new-static-list-item">
          <ListItem actions={[<NewsSource type={1} {...others} />]}>
            <NewsTitle {...props} tagType="static" />
          </ListItem>
        </div>
      );
    case 'resume':
      return (
        <ListItem>
          <SummaryItem {...props} />
        </ListItem>
      );
    case 'roll-resume':
      return <SummaryItem {...props} />;
    case 'bigCard':
    case 'smallCard':
      return (
        <div className="inbiz-new-card-list">
          <ListItem>
            <CardItem {...props} />
          </ListItem>
        </div>
      );
  }
  return <></>;
});

export default NewsItem;
